﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using HZ.MBSM.DBUtility;
public partial class Bidder_SuitTestimonyAdd : System.Web.UI.Page, HZ.MBSM.BLL.IPageDescribe
{
    private string strSort = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (HZ.MBSM.BLL.Login.CheckAssert(this.UseAccountType))
        {
     
            strSort = SysFun.IsSQL(Request.QueryString["Sort"].ToString());
            {
                if ((strSort != "1") && (strSort != "2"))
                {
                    return;
                }
                else if (strSort == "1") Label1.Text = "投诉";
                else if (strSort == "2") Label1.Text = "申述";
            }
        }


    }
    protected void sub_Click(object sender, EventArgs e)
    {
        Int64 AccountId;
       
        string strSql, strMsg;
        HZ.MBSM.Model.Account _Account = (HZ.MBSM.Model.Account)Session["Account"];
        if (_Account != null)
        {
            AccountId = SysFun.ToLong(_Account.AccountId);
            bool Speak = CheckNoSpeak(AccountId);
            if (!Speak) return;
            if (txtContent.Text.Trim().Length > 0 && txtTitle.Text.Trim().Length > 0)
            {
                if (txtTitle.Text.IndexOf("'") == -1 && txtContent.Text.IndexOf("'") == -1)
                {
                    strSql = "insert into SuitTestimony (accountid,TWname,Title,Content,TwTime,sort) values ('" + SysFun.ToTrim(AccountId) + "','" + _Account.DWName + "','" + SysFun.ToTrim(txtTitle.Text) + "','" + SysFun.ToTrim(txtContent.Text) + "','" + SysFun.ToTrim(DateTime.Now) + "'," + strSort + ")";
                    Db db = new Db();
                    db.Command(strSql);
                    
                    strMsg = "提交成功！";
                    db.Close();
                    HZ.MBSM.BLL.LogManage.RecordLoginDetail(_Account.AccountName, Request.UserHostAddress, "添加", "board", strSql, "../Magage/BoardAdd.aspx");

                }
                else
                {
                    strMsg = "输入的文本中含有非法字符如：’！";
                }

            }
            else
            {
                strMsg = "提问内容和标题都不能为空！";
            }
            Response.Write("<script language=JavaScript>alert('" + strMsg + "！！！');</script>");
        }
        else
        {
            Response.Write("<script language=JavaScript>alert('您还未登录，暂时无法留言！！！');</script>");
        }


    }
    private bool CheckNoSpeak(Int64 accountid)
    {
        string strsql = "select count(*) from CompanyDonotSpeak where accountid=" + accountid;
        Db db = new Db();
        DataTable da = db.DataTable(strsql);
        db.Close();
        if (da.Rows[0].ItemArray[0].ToString() == "1")
        {
            Response.Write("<script language=JavaScript>alert('你已被纳入禁言，无发发言！请与管理员联系。');</script>");
            return false;
        }
        return true;
    }
    #region IPageDescribe 成员

    public string Name
    {
        get { return "添加问题"; }
    }

    public string Describe
    {
        get { return "问题反馈"; }
    }

    public string ParentName
    {
        get { return "问题反馈"; }
    }

    public System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> UseAccountType
    {
        get
        {
            System.Collections.Generic.List<HZ.MBSM.DAL.AccountType> _AccountType = new System.Collections.Generic.List<HZ.MBSM.DAL.AccountType>();
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAdmin);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumAttorney);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumCompany);
            _AccountType.Add(HZ.MBSM.DAL.AccountType.enumHospitale);
            return _AccountType;
        }
    }
    #endregion
}
